﻿using System;


namespace RStudio.UIFramwork
{
    /// <summary>
    /// 
    /// </summary>
    public class HandlerUseRecord : IUIHandler
    {
        public IUIHandler Next { get; set; }

        public void Handle(UIBase uiBase)
        {
            if (uiBase.CanBeRecord)
            {
                UIEventArg uiEvent = new()
                {
                    Type = uiBase.GetType(),
                    UIEventType = UIEventType.Back,
                    UIBase = uiBase,
                };

                UIModuleCenter.Instance.UIModuleStack.Push(uiEvent);
            }

            Next?.Handle(uiBase);
        }


        /// <summary>
        /// 事件|记录
        /// </summary>

        public static event Action<UIEventArg> OnUIRecord;
    }
}